﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Small.PinBan
{
    public partial class FrmImportPhoto : Form
    {
        public FrmImportPhoto()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 递归找到文件夹下所有照片文件
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="inList"></param>
        public void  GetAllPicByDir(string inPath, List<string> inList)
        {
            string picTag = ".JPEG.JPG.TIF.BMP";   
            DirectoryInfo rootDir = new DirectoryInfo(inPath);
            if (rootDir.Exists)
            {
                FileInfo[] fileList = rootDir.GetFiles();
                foreach (FileInfo info in fileList)
                {
                    if (picTag.Contains(info.Extension.ToUpper()))
                    {
                        inList.Add(info.FullName);
                    }
                }
                DirectoryInfo[] listDir = rootDir.GetDirectories();
                foreach (DirectoryInfo dir in listDir)
                {
                    GetAllPicByDir(dir.FullName, inList);
                }
            }
         
        }

        private void FrmImportPhoto_Load(object sender, EventArgs e)
        {
            
            List<string> list=new List<string>();
            GetAllPicByDir(@"D:\Projects", list);
        }

    }
}
